/*     */ package com.qmsk.business.info.integralCash.controller;
/*     */ 
/*     */ import com.qmsk.business.bussBill.pbPaid.PbPaid;
/*     */ import com.qmsk.business.info.integralCash.dao.IntegralCashDao;
/*     */ import com.utils.gson.in.GsonHeadOneRow;
/*     */ import com.utils.gson.out.GsonEbRst;
/*     */ import com.utils.jdbc.connection.DbConnection;
/*     */ import com.utils.web.RequestUtils;
/*     */ import com.utils.web.ResponseUtils;
/*     */ import java.sql.SQLException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import org.apache.log4j.Logger;
/*     */ import org.springframework.beans.factory.annotation.Autowired;
/*     */ import org.springframework.stereotype.Controller;
/*     */ import org.springframework.transaction.annotation.Transactional;
/*     */ import org.springframework.web.bind.annotation.PathVariable;
/*     */ import org.springframework.web.bind.annotation.RequestMapping;
/*     */ 
/*     */ @Controller
/*     */ @RequestMapping({"/intCash"})
/*     */ public class IntegralCashController
/*     */ {
/*  29 */   private static final Logger logger = Logger.getLogger(IntegralCashController.class);
/*     */ 
/*     */   @Autowired
/*     */   private IntegralCashDao dao;
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/{pageIdx}/{pageSize}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getListAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("pageIdx") Integer nPageIdx, @PathVariable("pageSize") Short nPageSize)
/*     */   {
/*  55 */     nPageSize = RequestUtils.getRequestValidPageSize(nPageSize);
/*     */     try {
/*  57 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopId(shopId, nPageIdx, 
/*  58 */         nPageSize);
/*  59 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  61 */       logger.error(e);
/*  62 */       ResponseUtils.setErrorMsgResponse(
/*  63 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/stId/{shopId}/{stId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getIntegralCash(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("stId") Integer stId)
/*     */   {
/*     */     try
/*     */     {
/*  82 */       GsonEbRst gsonEbRst = this.dao.getGsonOfShopIdAndStId(shopId, stId);
/*  83 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/*  85 */       logger.error(e);
/*  86 */       ResponseUtils.setErrorMsgResponse(
/*  87 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/{shopId}/intAmtDisct/{st}/{memberId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getCashOfIntegralSt(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Object shopId, @PathVariable("st") String st, @PathVariable("memberId") Object memberId)
/*     */   {
/*     */     try
/*     */     {
/* 124 */       int stId = PbPaid.getStOfId(st);
/* 125 */       GsonEbRst gsonEbRst = this.dao.getCashOfIntegralRatio(shopId, stId, 
/* 126 */         memberId);
/* 127 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 129 */       logger.error(e);
/* 130 */       ResponseUtils.setErrorMsgResponse(
/* 131 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @RequestMapping(value={"find/shopId/groupCode/{shopId}/{groupCode}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*     */   public void getIntegralCashOfGroupCode(HttpServletRequest request, HttpServletResponse response, @PathVariable("shopId") Integer shopId, @PathVariable("groupCode") Integer groupCode)
/*     */   {
/*     */     try
/*     */     {
/* 150 */       GsonEbRst gsonEbRst = this.dao.getIntegralCashOfGroupCode(groupCode, 
/* 151 */         shopId);
/* 152 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*     */     } catch (SQLException e) {
/* 154 */       logger.error(e);
/* 155 */       ResponseUtils.setErrorMsgResponse(
/* 156 */         RequestUtils.getFindDataErrorMessage(request), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"insert"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void insert(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 172 */     String sGsonInData = RequestUtils.getString(request, "data");
/*     */     try {
/* 174 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 175 */       if (g != null) {
/* 176 */         Object stId = g.getValueOfName("stID");
/* 177 */         Object shopId = g.getValueOfName("shopId");
/* 178 */         Object ruleType = g.getValueOfName("ruleType");
/* 179 */         Object levelId = g.getValueOfName("levelId");
/* 180 */         if (this.dao.isExistsStIdRuleType(stId, shopId, ruleType, levelId).longValue() <= 0L)
/*     */         {
/* 182 */           int nResult = this.dao.insertGsonHeadOneRow(g);
/* 183 */           DbConnection.commit();
/* 184 */           ResponseUtils.setSqlResultResponse(nResult, 
/* 185 */             RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 186 */             response);
/* 187 */           return; }
/* 188 */         ResponseUtils.setErrorMsgResponse("服务类型或规则类别已使用，请重新选择", 
/* 189 */           response);
/*     */ 
/* 191 */         return; }
/* 192 */       ResponseUtils.setErrorMsgResponse(
/* 193 */         RequestUtils.getReadJsonDataErrorMessage(request), 
/* 194 */         response);
/*     */     }
/*     */     catch (Exception e) {
/* 197 */       DbConnection.rollback();
/* 198 */       logger.error(e);
/* 199 */       ResponseUtils.setErrorMsgResponse(
/* 200 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 201 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"del"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void delete(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 214 */     String id = RequestUtils.getStringOfId(request);
/*     */     try {
/* 216 */       String[] strParams = id.split(",");
/* 217 */       int nResult = this.dao.deleteParams(strParams);
/* 218 */       DbConnection.commit();
/* 219 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 220 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 221 */         response);
/*     */     } catch (Exception e) {
/* 223 */       DbConnection.rollback();
/* 224 */       logger.error(e);
/* 225 */       ResponseUtils.setErrorMsgResponse(
/* 226 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 227 */         e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ 
/*     */   @Transactional
/*     */   @RequestMapping(value={"edit"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*     */   public void update(HttpServletRequest request, HttpServletResponse response)
/*     */   {
/* 244 */     String id = request.getParameter("id");
/* 245 */     String sGsonInData = request.getParameter("data");
/*     */     try {
/* 247 */       GsonHeadOneRow g = GsonHeadOneRow.jsonStrToObject(sGsonInData);
/* 248 */       if (g == null) {
/* 249 */         ResponseUtils.setErrorMsgResponse(
/* 250 */           RequestUtils.getReadJsonDataErrorMessage(request), 
/* 251 */           response);
/* 252 */         return; }
/* 253 */       int nResult = 0;
/* 254 */       if ((id == null) || (id == "")) {
/* 255 */         ResponseUtils.setErrorMsgResponse("获取Id信息失败", response);
/* 256 */         return; }
/* 257 */       if ((g.getValueOfName("ruleType") != null) || 
/* 258 */         (g.getValueOfName("stID") != null) || 
/* 259 */         (g.getValueOfName("levelId") != null)) {
/* 260 */         Object stId = null;
/* 261 */         Object ruleType = null;
/* 262 */         Object levelId = null;
/* 263 */         GsonHeadOneRow r = this.dao.getIntegralCashOfId(id);
/* 264 */         if (g.getValueOfName("stID") != null)
/* 265 */           stId = g.getValueOfName("stID");
/*     */         else {
/* 267 */           stId = r.getValueOfName("stID");
/*     */         }
/*     */ 
/* 270 */         if (g.getValueOfName("ruleType") != null)
/* 271 */           ruleType = g.getValueOfName("ruleType");
/*     */         else {
/* 273 */           ruleType = r.getValueOfName("ruleType");
/*     */         }
/*     */ 
/* 276 */         if (g.getValueOfName("levelId") != null)
/* 277 */           levelId = g.getValueOfName("levelId");
/*     */         else {
/* 279 */           levelId = r.getValueOfName("levelId");
/*     */         }
/* 281 */         Object shopId = r.getValueOfName("shopID");
/* 282 */         nResult = this.dao.isExistsStIdRuleType_update(stId, shopId, 
/* 283 */           ruleType, levelId).intValue();
/* 284 */         if (nResult > 0) {
/* 285 */           ResponseUtils.setErrorMsgResponse(
/* 286 */             "服务类型或规则类别已使用，请重新选择", response);
/* 287 */           return;
/*     */         }
/*     */       }
/* 290 */       nResult += this.dao.updateJsonOneRow(g, id);
/* 291 */       if (nResult > 0)
/* 292 */         DbConnection.commit();
/*     */       else {
/* 294 */         DbConnection.rollback();
/*     */       }
/* 296 */       ResponseUtils.setSqlResultResponse(nResult, 
/* 297 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request), 
/* 298 */         response);
/*     */     }
/*     */     catch (Exception e)
/*     */     {
/* 302 */       DbConnection.rollback();
/* 303 */       logger.error(e);
/* 304 */       ResponseUtils.setErrorMsgResponse(
/* 305 */         RequestUtils.getSqlUpdateErrorMessage(sGsonInData, request) + 
/* 306 */         ":" + e.getMessage(), response);
/*     */     }
/*     */   }
/*     */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.integralCash.controller.IntegralCashController
 * JD-Core Version:    0.5.3
 */